//
//  TripItemTableViewCell.m
//  HappinessTrip
//
//  Created by dllo on 15/10/17.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "TripItemTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation TripItemTableViewCell
-(void)dealloc
{
    [_pictureImageView release];
    [_blackImageView release];
    [_lineImageView1 release];
    [_lineImageView2 release];
    [_nameLabel release];
    [_dianLabel1 release];
    [_dianLabel2 release];
    [_footLabel release];
    [_likeLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    _pictureImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_pictureImageView];
    [_pictureImageView release];
    _blackImageView = [[UIImageView alloc]init];
    [_pictureImageView addSubview:_blackImageView];
    [_blackImageView release];
    _lineImageView1 = [[UIImageView alloc]init];
    [_pictureImageView addSubview:_lineImageView1];
    [_lineImageView1 release];
    _lineImageView2 = [[UIImageView alloc]init];
    [_lineImageView1 addSubview:_lineImageView2];
    [_lineImageView2 release];
    _nameLabel = [[UILabel alloc]init];
    [_pictureImageView addSubview:_nameLabel];
    [_nameLabel release];
    _dianLabel1 = [[UILabel alloc]init];
    [_lineImageView2 addSubview:_dianLabel1];
    [_dianLabel1 release];
    _dianLabel2 = [[UILabel alloc]init];
    [_lineImageView2 addSubview:_dianLabel2];
    [_dianLabel2 release];
    _footLabel = [[UILabel alloc]init];
    [_lineImageView2 addSubview:_footLabel];
    [_footLabel release];
    _likeLabel = [[UILabel alloc]init];
    [_lineImageView2 addSubview:_likeLabel];
    [_likeLabel release];
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _pictureImageView.frame = CGRectMake(20 * W, 10 * H, self.contentView.frame.size.width - 40 * W, self.contentView.frame.size.height - 20 * H);
    _blackImageView.frame = CGRectMake(0, 0, _pictureImageView.frame.size.width, _pictureImageView.frame.size.height);
    _nameLabel.frame = CGRectMake(20 * W, 5 * H, _pictureImageView.frame.size.width - 40 * W, 40 * H);
    _lineImageView1.frame = CGRectMake(0, _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 50 * H, _pictureImageView.frame.size.width, 24 * H);
    _lineImageView2.frame = CGRectMake(0, 2 * H, _lineImageView1.frame.size.width, 20 * H);
    _dianLabel1.frame = CGRectMake(_nameLabel.frame.origin.x, 8 * H, 4 * W, 4 * W);
    _footLabel.frame = CGRectMake(_dianLabel1.frame.origin.x + _dianLabel1.frame.size.width + 5 * W, 0, 80 * W, _lineImageView2.frame.size.height);
    _dianLabel2.frame = CGRectMake(_footLabel.frame.origin.x + _footLabel.frame.size.width + 10 * W, _dianLabel1.frame.origin.y, _dianLabel1.frame.size.width, _dianLabel1.frame.size.height);
    _likeLabel.frame = CGRectMake(_dianLabel2.frame.origin.x + _dianLabel2.frame.size.width + 5 * W, _footLabel.frame.origin.y, _footLabel.frame.size.width, _footLabel.frame.size.height);
    
}
-(void)setTrip:(TripItems *)trip
{
    if (_trip != trip) {
        [_trip release];
        _trip = [trip retain];
    }
    [_pictureImageView sd_setImageWithURL:[NSURL URLWithString:_trip.cover_image_1600]placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _pictureImageView.layer.cornerRadius = 5;
    _pictureImageView.layer.masksToBounds = YES;
    _blackImageView.backgroundColor = [UIColor blackColor];
    _blackImageView.alpha = .2;
    _blackImageView.layer.cornerRadius = 5;
    _blackImageView.layer.masksToBounds = YES;
    _lineImageView2.backgroundColor = [UIColor blackColor];
    _lineImageView2.alpha = .8;
    _lineImageView1.backgroundColor = [UIColor grayColor];
    _lineImageView1.alpha = .4;
    
    _nameLabel.text = _trip.name;
    _nameLabel.textColor = [UIColor whiteColor];
    _nameLabel.font = [UIFont systemFontOfSize:20];
    _footLabel.text = [NSString stringWithFormat:@"%@ 足迹", _trip.waypoints];
    _footLabel.textColor = [UIColor whiteColor];
    _footLabel.font = [UIFont systemFontOfSize:13];
    _likeLabel.text = [NSString stringWithFormat:@"%@ 喜欢", _trip.recommendations];
    _likeLabel.textColor = [UIColor whiteColor];
    _likeLabel.font = [UIFont systemFontOfSize:13];
    _dianLabel1.backgroundColor = [UIColor whiteColor];
    _dianLabel1.layer.cornerRadius = 2 * W;
    _dianLabel1.layer.masksToBounds = YES;
    _dianLabel2.backgroundColor = [UIColor whiteColor];
    _dianLabel2.layer.cornerRadius = 2 * W;
    _dianLabel2.layer.masksToBounds = YES;
    
}

















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
